package day04;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

/**
 * 创建一个集合，存放元素"1","$","2","$","3","$","4"
 *   使用迭代器遍历集合，并在过程中删除所有的"$"，
 *   最后再将删除元素后的集合使用新循环遍历，并输出每一个元素。
 * @author Bonnie
 *
 */
public class Test02 {
    public static void main(String[] args) {
        String[] arr = {"1","$","2","$","3","$","4"};
        List<String> c1 = new ArrayList<>(Arrays.asList(arr));
        Iterator<String> it = c1.iterator();
        while (it.hasNext()){
            String s = it.next();
            if ("$".equals(s)){
                it.remove();
            }
        }

        for (String s : c1){
            System.out.println(s);
        }
    }
}
